from django.views.generic import ListView, DetailView, CreateView, \
                                 DeleteView, UpdateView, \
                                 ArchiveIndexView, DateDetailView, \
                                 DayArchiveView, MonthArchiveView, \
                                 TodayArchiveView, WeekArchiveView, \
                                 YearArchiveView


from events.models import EventsOfficial


class EventsOfficialView(object):
    model = EventsOfficial
    def get_template_names(self):
        """Nest templates within eventsofficial directory."""
        tpl = super(EventsOfficialView, self).get_template_names()[0]
	print tpl
        app = self.model._meta.app_label
        mdl = 'eventsofficial'
        self.template_name = 'events/eventsofficial/eventsofficial_list.html' #tpl.replace(app, '{0}/{1}'.format(app, mdl))
        return [self.template_name]

    def create(self):
	self.template_name = 'events/eventsofficial/eventsofficial_form.html'
	return [self.template_name]

    '''
    def index(request):
	latest_events = model.objects.all()
	return render_to_response('events/eventsofficial/eventsofficial_list.html',{'content':latest_events})
    '''

class EventsOfficialDateView(EventsOfficialView):
    date_field = 'create_time'
    month_format = '%m'


class EventsOfficialBaseListView(EventsOfficialView):
    paginate_by = 10


class EventsOfficialArchiveIndexView(
    EventsOfficialDateView, EventsOfficialBaseListView, ArchiveIndexView):
    pass


class EventsOfficialCreateView(EventsOfficialView, CreateView):
    pass


class EventsOfficialDateDetailView(EventsOfficialDateView, DateDetailView):
    pass


class EventsOfficialDayArchiveView(
    EventsOfficialDateView, EventsOfficialBaseListView, DayArchiveView):
    pass


class EventsOfficialDeleteView(EventsOfficialView, DeleteView):

    def get_success_url(self):
        from django.core.urlresolvers import reverse
        return reverse('events_eventsofficial_list')


class EventsOfficialDetailView(EventsOfficialView, DetailView):
    pass


class EventsOfficialListView(EventsOfficialBaseListView, ListView):
    pass


class EventsOfficialMonthArchiveView(
    EventsOfficialDateView, EventsOfficialBaseListView, MonthArchiveView):
    pass


class EventsOfficialTodayArchiveView(
    EventsOfficialDateView, EventsOfficialBaseListView, TodayArchiveView):
    pass


class EventsOfficialUpdateView(EventsOfficialView, UpdateView):
    pass


class EventsOfficialWeekArchiveView(
    EventsOfficialDateView, EventsOfficialBaseListView, WeekArchiveView):
    pass


class EventsOfficialYearArchiveView(
    EventsOfficialDateView, EventsOfficialBaseListView, YearArchiveView):
    make_object_list = True



